#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

typedef struct
{
    int front;
    int rear;
    int* nums;
    int k;
} MyCircularQueue;


MyCircularQueue* myCircularQueueCreate(int k)
{
    MyCircularQueue* obj = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
    obj->nums = (int*)malloc(sizeof(int) * (k + 1));
    obj->front = obj->rear = 0;
    obj->k = k + 1;

    return obj;
}
bool myCircularQueueIsEmpty(MyCircularQueue* obj)
{
    return obj->front == obj->rear;
}

bool myCircularQueueIsFull(MyCircularQueue* obj)
{
    return ((obj->rear + 1) % (obj->k)) == obj->front;
}

bool myCircularQueueEnQueue(MyCircularQueue* obj, int value)
{
    if (myCircularQueueIsFull(obj))
    {
        return false;
    }
    obj->nums[obj->rear] = value;
    obj->rear++;
    obj->rear %= obj->k;
    return true;
}

bool myCircularQueueDeQueue(MyCircularQueue* obj)
{
    if (myCircularQueueIsEmpty(obj))
    {
        return false;
    }
    obj->front++;

    obj->front %= obj->k;
    return true;
}

int myCircularQueueFront(MyCircularQueue* obj)
{
    if (myCircularQueueIsEmpty(obj))
    {
        return -1;
    }

    return obj->nums[obj->front];
}

int myCircularQueueRear(MyCircularQueue* obj)
{
    if (myCircularQueueIsEmpty(obj))
    {
        return -1;
    }

    return obj->nums[(obj->rear + obj->k - 1) % obj->k];
}


void myCircularQueueFree(MyCircularQueue* obj)
{
    free(obj->nums);
    free(obj);
}
int main()
{
	return 0;
}